import React, { Component } from 'react'
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import { userService } from '../../service'
import {userAction} from '../../actions';

class MakeUser extends Component {

    constructor(props) {
　　　　super(props);
　　　　console.log("取得状态");
       console.log(this.props);
　　}


    render() {
        console.log("-----------------MakeUser渲染----------------------")
        console.log(this.props.userInfo);
        const {id,name,pwd,phone} = this.props.userInfo.user;
        return (
            <div>
                <form>
                    <input name='id' value={id}/>
                    <input name='name' value={name}/>
                    <input name='pwd' value={pwd}/>
                    <input name='phone' value={phone}/>
                </form>
            </div>
        )
    }
}

//连接state到props
const mapStateToProps = state => {
    console.log("hhhhhhhhhMAkeUserhhhhhhhhhhhhh");
    console.log(state);
    return{
        userInfo: state.userMakeReducer
    }
}

const mapDispatchToProps = (dispatch) =>{
    console.log("mackeUser==============dis")
    console.log(userAction);
    return{
        actions:bindActionCreators(userAction,dispatch),
        dispatch:dispatch
    }
}


export default connect(
    mapStateToProps,mapDispatchToProps
)(MakeUser);